package io.github.frailty9.crserver.dto

import io.github.frailty9.crserver.model.Account
import io.github.frailty9.crserver.model.BaseModel
import io.github.frailty9.crserver.model.User
import io.github.frailty9.crserver.model.toDto
import org.noear.snack.annotation.ONodeAttr

/**
 * 用于接收注册请求的DTO
 */
data class RegisterDto(
    val username: String,
    val password: String,
    val role: String,
    val userInfo: User,
)

/**
 * 用于返回登陆后用户信息的DTO
 *
 * 继承BaseModel, 便于调用toDto()
 */
data class UserInfoDto(
    val username: String,
    val role: String,
    val userInfo: User,
) : BaseModel {
    @ONodeAttr(ignore = false)
    override var id: Long? = null
    @ONodeAttr(ignore = false)
    override var version: Int? = null
    @ONodeAttr(ignore = false)
    override var deleted: Int? = null

    fun toDto(): UserInfoDto {
        userInfo.toDto()
        return this
    }
}

/**
 * 用于给管理员返回用户账户信息的DTO
 */
data class AccountInfo(
    var account: Account? = null,
    var user: User? = null
)
